Skip to content

printer: ignore EAGAIN and EINTR errno#903

Merged
michalvasko merged 1 commit intoCESNET:masterfrom
6WIND:printer-eagain
Oct 16, 2019
Merged

printer: ignore EAGAIN and EINTR errno#903
michalvasko merged 1 commit intoCESNET:masterfrom
6WIND:printer-eagain

Conversation

@rjarry
Copy link
Copy Markdown
Collaborator

@rjarry rjarry commented Oct 15, 2019

When using libnetconf2 via the UNIX or FD transport and sending large configs, we can get the following error from libyang:

Print error (Resource temporarily unavailable).

Do not fail when errno holds EAGAIN or EINTR. These are not errors. This can occur when using ly_print_clb with a callback that does I/O on a non-blocking file or if the application received a signal during the write syscall.

Ideally, we should check the return value of every ly_print call but it would be rather tedious and would make the code clobbered.

Fixes: 609d708 ("printer CHANGE use errno to check for printer errors")

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 15, 2019

Codecov Report

Merging #903 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #903      +/-   ##
==========================================
+ Coverage   74.77%   74.77%   +<.01%     
==========================================
  Files          34       34              
  Lines       40119    40121       +2     
  Branches    10171    10172       +1     
==========================================
+ Hits        29997    29999       +2     
  Misses      10122    10122

@michalvasko
Copy link
Copy Markdown
Member

Hi,
I do not particularly like your fix. I was thinking that it could be fixed instead in the way that if the user callback returns 0 or a positive number, errno gets zeroed. What do you think?

Regards,
Michal

@rjarry
Copy link
Copy Markdown
Collaborator Author

rjarry commented Oct 15, 2019

@michalvasko That is a little better indeed, I'll submit an update.

When using libnetconf2 via the UNIX or FD transport and sending large
configs, we can get the following error from libyang:

  Print error (Resource temporarily unavailable).

Do not fail when errno holds EAGAIN or EINTR. These are not errors. This
can occur when using ly_print_clb with a callback that does I/O on
a non-blocking file or if the application received a signal during the
write syscall.

If the callback function returns a zero or positive value, reset errno
so that LY_PRINT_RET does not return an error.

Fixes: 609d708 ("printer CHANGE use errno to check for printer errors")
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
@michalvasko
Copy link
Copy Markdown
Member

Hi,
seems fine now, merging.

Regards,
Michal

@michalvasko michalvasko merged commit 75d2ed7 into CESNET:master Oct 16, 2019
@brchiu
Copy link
Copy Markdown
Contributor

brchiu commented Oct 16, 2019

hi, @michalvasko , will this commit apply to devel branch too ? otherwise, these two branches will diverge.

@michalvasko
Copy link
Copy Markdown
Member

Yes, it was already merged.

@rjarry
Copy link
Copy Markdown
Collaborator Author

rjarry commented Oct 16, 2019

Thanks @michalvasko

@rjarry rjarry deleted the printer-eagain branch October 16, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants